package JZ.JZ41;

import java.util.ArrayList;
import java.util.List;

/**
 * @author corn
 * @create 2020-10-23-23:28
 */

public class Solution {

    public ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
        ArrayList<ArrayList<Integer>> lists = new ArrayList<ArrayList<Integer>>();
        for(int i = 1; i<sum/2; i++){
            ArrayList<Integer> list = new ArrayList<>();
            list.add(i);
            int aSum = sum - i;
            int ai = i;
            //但和大于0时，继续向下减
            while(aSum > 0){
                ai++;
                aSum -= ai;
                if(aSum == 0){
                    lists.add(list);
                }
                list.add(ai);
            }
        }
        return lists;
    }
}